package logic

import (
	"context"
	"medi-doc/model"

	"medi-doc/doctorrpc/doctorrpc"
	"medi-doc/doctorrpc/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type DoctorAddLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewDoctorAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DoctorAddLogic {
	return &DoctorAddLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *DoctorAddLogic) DoctorAdd(in *doctorrpc.DoctorAddRequest) (*doctorrpc.DoctorAddResponse, error) {
	// todo: add your logic here and delete this line

	doctor := model.Doctor{

		Name:    in.Name,
		Img:     in.Img,
		Address: in.Address,
		Zw:      in.Zw,
		Class:   in.Class,
		Bq:      in.Bq,
	}
	model.DB.Debug().Create(&doctor)
	return &doctorrpc.DoctorAddResponse{
		Id: int64(doctor.ID),
	}, nil
}
